<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>教室列表</h2>
	</div>
	<div class="cf">
		<div class="fl">
            <a class="btn" href="{:U('addBatch')}">批量添加</a>
            <a class="btn" href="{:U('addOne')}">单独添加</a>
        </div>
        
        <!-- 搜索开始 -->
        <style>.form-horizontal .form-item{display:inline;} .form-horizontal .item-label{display:inline;}</style>
		<form action="{:U('')}" method="POST" class="form-horizontal" style="float:right;">
			<div class="form-item">
	            <label class="item-label">所属学校</label>
               <select name="school_id" onChange="getBuildings(this);">
               	<option value="0">请选择</option>
               	<volist name="schoolList" id="vo">
                    <option value="{$vo.id}" <if condition="I('school_id') eq $vo['id']">selected="selected"</if> >{$vo.title}</option>
                </volist>
               </select>
	        </div>
	        
	        <div class="form-item">
            	<label class="item-label">教学楼</label>
               <span id="building_container">
	               <select name="building_id_empty">
	               	<option value="0">请选择</option>
	               </select>
               </span>
	        </div>
		    <div class="form-item">
		        <button class="btn" id="" type="submit">确 定</button>
		    </div>
		</form>
        <!-- 搜索结束 -->
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
	<table class="">
    <thead>
        <tr>
		<th class="">名称</th>
		<th class="">学校</th>
		<th class="">建筑</th>
		<th class="">坐标</th>
		<th class="">操作</th>
		</tr>
    </thead>
    <tbody>
		<notempty name="_list">
		<volist name="_list" id="vo">
		<tr>
			<td>{$vo.title}</td>
			<td><?php echo parse_id_to_string($vo['school_id'], 'school_id'); ?></td>
			<td><?php echo parse_id_to_string($vo['building_id'], 'building_id'); ?></td>
			<td>{$vo.coordinate}</td>
			<td>
				<a href="{:U('Classroom/edit?id='.$vo['id'])}">编辑</a>
				|
				<a href="{:U('Classroom/del?id='.$vo['id'])}" class="confirm ajax-get">删除</a>
			</td>
		</tr>
		</volist>
		<else/>
		<td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
		</notempty>
	</tbody>
    </table>
	</div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
	<script type="text/javascript">
	function getBuildings(obj){
		var v = obj.value;
		if (parseInt(v) > 0){
    		var url = Think.APP + Think.DEEP + 'Common' + Think.DEEP + 'getBuildingsAjax' + Think.DEEP + 'school_id' + Think.DEEP + v;
			$.get(url, function(data){
				$('#building_container').empty().html(data);
			});
		}
	}
	
    //导航高亮
    highlight_subnav('{:U('Teacher/index')}');
	</script>
</block>
